<!DOCTYPE html>
<html lang='en'>
<head>
    <meta charset='UTF-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script src='../vue.js'></script>
</head>
<body>
    <div id='app'>
        <h1>计数器{{count}}</h1>
        <!-- prevent修饰符: 可以阻止默认事件,常见于from表单的submit事件 -->
        <button @contextmenu.prevent="">右键</button>
        <br>
        <!-- .stop修饰符: 阻止传播 -->
        <div @click="fn1">
            div1-1
            <div @click.stop="fn2">div1-2</div>
        </div>
        <br>
        <!-- .capture修饰符: 把事件传播方式改为捕获 -->
        <div @click.capture="fn1">
            div2-1
            <div @click="fn2">div2-2</div>
        </div>
        <br>
        <!-- .self修饰符: 当事件被触发时候e.target是否是自身,如果是在触发事件 -->
        <div @click.self="fn1">
            div3-1
            <div @click="fn2">div3-2</div>
        </div>
        <br>
        <!-- .once修饰符: 一次性事件 -->
        <button @click.once="fn1">once</button>
    </div>
    <script>
        Vue.config.productionTip = false;
        const vm = new Vue({
            el:'#app',
            data(){
                return {
                count:0
            }
            },
            methods:{
                fn1(){
                    console.log('fn1111');
                },
                fn2(){
                    console.log('fn2222');
                }
            }
    })
    </script>
</body>
</html>